#include "../game_server.cpp"
#include "../user.cpp"
#include "../room.cpp"
#include "../protocol_dist.hpp"
#include "ws_websocket.hpp"
#include <iostream>

using namespace std;
FASTDO_API void ActionMain(ProtocolC2SLogoutUser *msg, pWsReqCtx ctx, GameServer &game)
{
    cout << "ctxId:" << ctx->clientId << endl;
    ProtocolS2CLogoutUser rtn;
    for (auto user : game.userList)
    {
        if (!user->isLogged)
        {
            continue;
        }
        if (user->isYourCtx(ctx))
        {
            user->logout();
            rtn.ok = true;
        }
    }
    ctx->send(ws::OpCode::dataText, false, rtn.toMixed().json());
}